<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../css/index.css" />
		<link rel="stylesheet" href="../css/login.css">
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/vant.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/ajax.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			
			document.addEventListener('plusready', function(){
				//console.log("所有plus api都应该在此事件发生后调用，否则会出现plus is undefined。"
				
			});
			
		</script>
		<title></title>
		
	</head>

	<body>
		<div id="app">
			<van-row>
				 <van-col span="24" id="login_img">
				 	<img src="../img/logins.PNG" />
				 </van-col>
			</van-row>
			<van-row>
				 <van-col span="24">
					  <van-field
					    v-model="phone"
					    label="手机号"
					    placeholder="请输入手机号"
					    left-icon="phone-o"
					    error-message=""
					    id="ph"
					  />
				 </van-col>
			</van-row>
			<van-row>
				 <van-field
				    v-model="password"
				    type="password"
				    label="密码"
				    placeholder="请输入密码"
				    left-icon="wap-home"
				    id="pwd"
				  />
				 </van-col>
			</van-row>
			<van-row>
				 <van-col span="24" id="wjpwd">
				  <a href="#" onclick="wjpwd()">忘记密码？</a>
				 </van-col>
			</van-row>
			<van-row>
				 <van-col span="24" id="dl">
				 	<van-button size="large" square type="danger" @click="dl">立即登录</van-button>
				 </van-col>
			</van-row>
			<van-row>
				 <van-col span="24" id="zc">
				 	<a href="#" onclick="zezh()" >还没有注册，立即注册</a>
				 </van-col>
			</van-row>
			
		</div>
		<script type="text/javascript">
			
		var _this=this;
			var app = new Vue({
				el: "#app",
				data: {
					phone:"",
					password:""
				},
				created() {
					localStorage.clear();
				},
				methods:{
					dl:function(){
						var _this=this;
						ajax({
							url:"http://dsapi.ysd3g.com/api/login",
							dataType:"JSONP",
							data:{
								account:_this.phone,
								password:_this.password
							},	
							success:function(res){
								console.log(res);
								if(res.Error == true){
									app.$toast("登录失败");
								}
								else{
									app.$toast("登录成功");
									//console.log(res.Key)
									localStorage.setItem("keys",res.Key);
									var setting = plus.webview.getWebviewById("user");
									setting.reload(true);
									//console.log(res.UserData.NickName);
									localStorage.setItem("name",res.UserData.NickName);	
									localStorage.setItem("phone",res.UserData.Phone);
									plus.webview.close(plus.webview.currentWebview());
								}
							}
							
						});
					}
				}
			});
		</script>
		<script type="text/javascript">
			function wjpwd(){
				plus.webview.open("","")
			}
			function zezh(){
				plus.webview.open("zhuce.html","zc")
			}
		</script>
	</body>
</html>